import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader'
import { AssetContainer } from '../AssetContainer.js'

// function getDracoLoader({ path }) {
//     const dracoLoader = new DRACOLoader()
//     dracoLoader.setDecoderPath(path)
//     dracoLoader.setDecoderConfig({ type: 'js' })
//     return dracoLoader
// }
// const dracoLoader = getDracoLoader({ path: '/gltf/' })

class MyGLTFLoader extends GLTFLoader {
    static instance = null
    constructor(manager) {
        super(manager)
        // this.setDRACOLoader(dracoLoader)
    }
    async load({ id, url }) {
        // return new Promise((resolve, reject) => {
        super.load(url, async (gltf) => {
            // wait until the model can be added to the scene without blocking due to shader compilation
            // await renderer.compileAsync(model, camera, scene)

            AssetContainer.instance.set(id, gltf.scene)
            // resolve(model)
        })
        // })
    }
}

export { MyGLTFLoader }
